package applet;
import processing.core.PApplet;
import db.*;
import java.util.*;
import java.util.Map.Entry;
import lmf.*;
import musicbrainz.*;
import net.HTTPConnection;

public class RadioGaga extends PApplet {

	public GLOBAL g = new GLOBAL(this);
	//ArtistButton artistsTestButton;
	ArtistDragMenu artistSelectPanel;
	FilterPanel filter;
	
	TrackMenu testTrackMenu;
	ArrayList<TrackButton> trackButtons; //should be replaced by GLOBAL var
	
	ReleaseMenu testReleaseMenu;
	ArrayList<ReleaseButton> releaseButtons;
	
	
	ArrayList<Clock> countryClock;
	
	public void setup()
	{
		size(1024, 768);
		GLOBAL.countries_times = new ArrayList<Country>();

//Commented after v78/////////////////////////////////////////////////////////////////////////////

		GLOBAL.db = new DBConnection();
		GLOBAL.db.run();
		
		GLOBAL.http = new HTTPConnection();
//End of comment after v78/////////////////////////////////////////////////////////////////////////////

		
		//GLOBAL.processing.frameRate(160);
		GLOBAL.processing.smooth();
		setupColors();
		
		GLOBAL.tFont = createFont("Segoe UI", 16);
		GLOBAL.tFont32 = createFont("Segoe UI", 32);
		GLOBAL.fontTimes12 = createFont("TimesNewRomanPSMT", 12);
		GLOBAL.gu = new GuiGradient();
		
		GLOBAL.tabs = new TabGroup(0,0,1024,768,3);
		GLOBAL.tabs.tagHeight = 100;
		GLOBAL.tabs.tagWidth = 50;
		for(int i= 0; i < 3; i++) {
			GLOBAL.tabs.selected[i] = GLOBAL.processing.loadImage(GLOBAL.baseDir + "selected0.bmp");
			GLOBAL.tabs.unselected[i] = GLOBAL.processing.loadImage(GLOBAL.baseDir + "unselected0.bmp");
			GLOBAL.tabs.tabColor[i] = 64;
		}
		
		  
		//artistsTestButton = new ArtistButton(); 
		//artistsTestButton.x = 240;
		//artistsTestButton.y = 80;
		//artistsTestButton.setLabel("artistButton 1");
		

		  
		  //test.setIcon(GLOBAL.baseDir + "downarrow.png",GLOBAL.baseDir + "uparrow.png");
		  //test.setIcon("data/DownArrow.png","data/Uparrow.png");
		  //test.setIcon("DownArrow.png","UpArrow.png");
		  //artistSelectPanel.setLabel("ARTISTS");
		  GLOBAL.items = new ArrayList<ArtistButton>();
		  GLOBAL.artistRecommendationsIds = new ArrayList<Integer>();
		  
//Commented after v78/////////////////////////////////////////////////////////////////////////////
		  GLOBAL.db.getArtistNamesByTotalPopularity(0,10000);	//temporarily using a small subset for debugging
//End of comment after v78/////////////////////////////////////////////////////////////////////////////
		  
		  //db.getArtistNamesByTotalPopularity(0,1844674407379551615L);	//using large random value to get all of them
		 // ArtistButton a = new ArtistButton();
		 //    a.setLabel("Loading Artists.... Please Wait");
		  
//Uncommented after v78~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//		  for(int i = 0; i<10000; i++)
//	      {
//	  	     ArtistButton a = new ArtistButton();
//	  	     a.artist = new Artist(i,"","",0);
//		     a.setLabel("ArtistName " + i);
//		     GLOBAL.items.add(a);
//	      }
//End of uncommented~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	   
		  lmf.WeeklyChartLFM weeklyChart = GLOBAL.http.getLFMWeeklyChart();
		  GLOBAL.weeklyButtons = new ArrayList<WeeklyButton>();
		  for(int i= 0; i< weeklyChart.getSize(); i++) {
			  WeeklyButton wb  = new WeeklyButton();
			  wb.weeklyData = new WeeklyData();
			  wb.weeklyData.bio = weeklyChart.getArtist(i).bio;
			  wb.weeklyData.image_large = weeklyChart.getArtist(i).image_large;
			  wb.weeklyData.last_fm_url = weeklyChart.getArtist(i).last_fm_url;
			  wb.weeklyData.listeners = weeklyChart.getArtist(i).listeners;
			  wb.weeklyData.mbid = weeklyChart.getArtist(i).mbid;
			  wb.weeklyData.name = weeklyChart.getArtist(i).name;
			  wb.weeklyData.playcount = weeklyChart.getArtist(i).playcount;
			  wb.weeklyData.summary = weeklyChart.getArtist(i).summary;
			  wb.setLabel(wb.weeklyData.name);
			  
			  GLOBAL.weeklyButtons.add(wb);
		  }
		  GLOBAL.weeklyMenu = new WeeklyDragMenu(80,20,GLOBAL.weeklyButtons);
		  GLOBAL.weeklyMenu.setLabel("");
		  GLOBAL.weeklyMenu.dragDownSize = 20;
		  
		  GLOBAL.weeklyDataCurrent = GLOBAL.weeklyMenu.items.get(0).weeklyData;
		  GLOBAL.weeklyImage = GLOBAL.processing.loadImage(GLOBAL.weeklyDataCurrent.image_large);
		  
			
	      artistSelectPanel = new ArtistDragMenu(80,20,GLOBAL.items);
	      artistSelectPanel.setLabel(""); //necessary
	      
		  filter = new FilterPanel(50,5,950,20);
		  
		
		ArrayList<ChartElement> testPieElement = new ArrayList<ChartElement>();
		ChartElement[] testPEArray = new ChartElement[20];
		for(int i = 0; i< 20; i++) {
			testPEArray[i] = new ChartElement(100*(i+1),"Test "+i);
			testPieElement.add(testPEArray[i]);
		}
		
		ArrayList<ChartElement> testBarElement = new ArrayList<ChartElement>();
		ChartElement[] testBEArray = new ChartElement[10];
		for(int i = 0; i< 10; i++) {
			testBEArray[i] = new ChartElement(200*(i+1),i*10+"");
			testBarElement.add(testBEArray[i]);
		}

		GLOBAL.testPie = new PieChart(285,290,150,testPieElement);//,false);
		
//		ArrayList<PieElement> test2 = new ArrayList<PieElement>();
//		test2.add(new PieElement(6600,"Other"));
//		test2.add(new PieElement(21000-6600,"First ten"));
		
		GLOBAL.testGPie = new GenderPieChart(650,320,100,6600,21000-6600);	
		
		GLOBAL.testBar = new BarChart(620, 130, 150, 150, testBarElement);
		
		GLOBAL.map = new MyMap();
		
		int[] testCount = new int[24];
		for(int i = 0; i < 24; i++) {
			testCount[i] = 10*(i+1);
		}
		GLOBAL.testArtist = new Artist(0,"","",0);
		
		GLOBAL.block = new CompareRegion[4];
		for(int i = 0; i < 4; i++) {
			GLOBAL.block[i] = new CompareRegion(285, 50+170*i, 719, 160);
		}
		GLOBAL.artistsCompareList = new ArrayList<Artist>();
		
//Commented after v78/////////////////////////////////////////////////////////////////////////////
		if(GLOBAL.getItemsSize() >0) {
			GLOBAL.testArtist = GLOBAL.items.get(0).artist;
			GLOBAL.db.getArtistInfo(GLOBAL.testArtist);// GLOBAL.testArtist is valid from this line
			GLOBAL.testGPie.updateNumber(GLOBAL.testArtist.recordsCountBySex[1],GLOBAL.testArtist.recordsCountBySex[0]);
			ArrayList<ChartElement>newAgeData = new ArrayList<ChartElement>();
			for(int i = 0; i < GLOBAL.testArtist.recordsCountByAge.length; i++) {
				newAgeData.add(new ChartElement(GLOBAL.testArtist.recordsCountByAge[i], i*10+""));
			}
			GLOBAL.testBar.setData(newAgeData);

			ArrayList<ChartElement>newCountryData = new ArrayList<ChartElement>();
			
			Iterator<Entry<String, Long>> it = GLOBAL.testArtist.recordsCountByCountries.entrySet().iterator();
			while (it.hasNext()) {
			     Map.Entry<String, Long> pairs = (Map.Entry<String, Long>) it.next();
//			     System.out.println(pairs.getKey() + " = " + pairs.getValue());
				 newCountryData.add(new ChartElement(pairs.getKey(), pairs.getValue()));

			}
			GLOBAL.testPie.setData(newCountryData);
//			PApplet.println(GLOBAL.testArtist.mbid);
//			GLOBAL.testArtist.LFMInfo = GLOBAL.http.getLFMArtistInfo(GLOBAL.testArtist.mbid);
//			GLOBAL.testArtist.MBInfo = GLOBAL.http.getMBAristInfo(GLOBAL.testArtist.mbid);
			lmf.ArtistLFM lfmInfo = GLOBAL.http.getLFMArtistInfo(GLOBAL.testArtist.mbid);
			if(lfmInfo.image_large!="") {
				GLOBAL.testImage=GLOBAL.processing.loadImage(lfmInfo.image_large);
			}
			else {
				GLOBAL.testImage=GLOBAL.processing.loadImage(GLOBAL.baseDir + "noImage.jpg");
			}
		}

//End of comment after v78/////////////////////////////////////////////////////////////////////////////

		GLOBAL.relationTree = new DynTree(780,46,225,409,1/*GLOBAL.testArtist.id*/);
		
		//AlbumArrayLFM albumSet = GLOBAL.http.getTopAlbumsByArtist(GLOBAL.testArtist.mbid);
		//GLOBAL.curRelease = testReleaseMenu.items.get(GLOBAL.curReleaseId).release;
		//GLOBAL.curTrack = testTrackMenu.items.get(GLOBAL.curTrackId).track;
		
		releaseButtons = new ArrayList<ReleaseButton>();
		//you should import the music brainz package
		ReleaseArrayMB releaseArray= GLOBAL.http.getMBReleaseInfoFromArtist(GLOBAL.testArtist.mbid, 200, 0);
		if(releaseArray != null)
		for(int i=0; i<releaseArray.arr.size(); i++)
		{
			ReleaseMB tmp = releaseArray.arr.get(i);
			Release b = new Release(tmp.mbid,tmp.status, tmp.title, tmp.quality, tmp.language,tmp.script,tmp.date,tmp.country);
			if(i==0)
				GLOBAL.curRelease = b;
			ReleaseButton a = new ReleaseButton();
			a.release = b;
			a.setLabel(b.title);
			releaseButtons.add(a);
		}
		testReleaseMenu = new ReleaseMenu(75,500, releaseButtons);
		testReleaseMenu.setLabel("");
		
		
		trackButtons = new ArrayList<TrackButton>();
		RecordingArrayMB trackArray = GLOBAL.http.getMBSongInfoFromRelease(GLOBAL.curRelease.mbid/*testReleaseMenu.items.get(GLOBAL.curReleaseId).release.mbid*/);
		for(int i = 0; i<trackArray.arr.size(); i++)
		{
			RecordingMB tmp1 = trackArray.arr.get(i);
			Track b1 = new Track(tmp1.mbid,tmp1.title,tmp1.length);
			if(i==0)
				GLOBAL.curTrack = b1;
			TrackButton a1 = new TrackButton();
			a1.track = b1;
			a1.setLabel(b1.title);
			trackButtons.add(a1);
		}
		testTrackMenu = new TrackMenu(547,500,trackButtons);
		testTrackMenu.setLabel("");
		
		
		
		GLOBAL.db.getCountryTimes();
		countryClock = new ArrayList<Clock> ();
		for(int i = 0; i< GLOBAL.countries_times.size(); i++) {
			countryClock.add(new Clock(GLOBAL.countries_times.get(i).latitude, GLOBAL.countries_times.get(i).longitude, GLOBAL.countries_times.get(i).time_zone, GLOBAL.countries_times.get(i).hours_counts, GLOBAL.countries_times.get(i).name));
		}		//testClock = new Clock(35,105,8,testCount);

	}
	
	public void draw()
	{

//		PApplet.println("id "+GLOBAL.testArtist.id +" men "+GLOBAL.testArtist.recordsCountBySex[1]+" women "+GLOBAL.testArtist.recordsCountBySex[0]);
//		PApplet.println("compareMode: "+GLOBAL.artistsCompare);
//		PApplet.println("compareArtistsnumber: "+GLOBAL.artistsCompareList.size());

//		PApplet.println("Count!!! "+GLOBAL.countries_times.size());
		//background
		GLOBAL.processing.background(192);//GLOBAL.colorBackground);
		GLOBAL.tabs.draw();
		GLOBAL.onCompareRegion = false;

		//PApplet.println("onItem= "+filter.artistList.onItem);

		if(GLOBAL.tabs.currentTabIndex == 0) {
//			GLOBAL.testPie.draw();
//			GLOBAL.testGPie.draw();
//			GLOBAL.testBar.draw();
			
			//artistsTestButton.draw();
			
			//if(GLOBAL.getItemsSize() > 0)	//needed because we are running multiple threads
			//	artistSelectPanel.draw();
			
			/*ReleaseArrayMB releaseArray= GLOBAL.http.getMBReleaseInfoFromArtist(GLOBAL.testArtist.mbid, 200, 0);
			
			for(int i=0; i<releaseArray.arr.size(); i++)
			{
				ReleaseMB tmp = releaseArray.arr.get(i);
				Release b = new Release(tmp.mbid,tmp.status, tmp.title, tmp.quality, tmp.language,tmp.script,tmp.date,tmp.country);
				ReleaseButton a = new ReleaseButton();
				a.release = b;
				a.setLabel(b.title);
				releaseButtons.add(a);
			}
			testReleaseMenu = new ReleaseMenu(75,500, releaseButtons);
			testReleaseMenu.setLabel("");
			
			
			trackButtons = new ArrayList<TrackButton>();
			RecordingArrayMB trackArray = GLOBAL.http.getMBSongInfoFromRelease(testReleaseMenu.items.get(GLOBAL.curReleaseId).release.mbid);
			for(int i = 0; i<trackArray.arr.size(); i++)
			{
				RecordingMB tmp1 = trackArray.arr.get(i);
				Track b1 = new Track(tmp1.mbid,tmp1.title,tmp1.length);
				TrackButton a1 = new TrackButton();
				a1.track = b1;
				a1.setLabel(b1.title);
				trackButtons.add(a1);
			}
			testTrackMenu = new TrackMenu(547,500,trackButtons);
			testTrackMenu.setLabel("");*/
			
			
			
		//testTrackMenu.draw();
		//testReleaseMenu.draw();
		//test: draw FilterPanel

			//test: draw FilterPanel
			//artistSelectPanel.draw();
			
			if(GLOBAL.artistsCompare==false) {
				
				testTrackMenu.draw();
				testReleaseMenu.draw();
				
				GLOBAL.processing.textFont(GLOBAL.tFont32);
				GLOBAL.processing.textAlign(PApplet.LEFT,PApplet.TOP);
				GLOBAL.processing.fill(224);
				GLOBAL.processing.text(GLOBAL.testArtist.name, 285,50);
			
				GLOBAL.testPie.draw();
				GLOBAL.testGPie.draw();
				GLOBAL.testBar.draw();
				GLOBAL.processing.imageMode(PApplet.CORNER);
				GLOBAL.processing.image(GLOBAL.testImage, 285, 100,GLOBAL.testImage.width*150.0f/GLOBAL.testImage.height, 150);
			
				//if(GLOBAL.draggedToDynTree)
				//{
				//	GLOBAL.relationTree.redraw();
				//	GLOBAL.draggedToDynTree = false;
				//}
				GLOBAL.relationTree.draw();
			}
			else {
				for (int i = 0; i <4; i++) {
					GLOBAL.block[i].draw();
					if(GLOBAL.block[i].mouseOver()) {
						GLOBAL.onCompareRegion = true;
					}
					
				}

				GLOBAL.processing.textFont(GLOBAL.tFont32, 28);
				GLOBAL.processing.textAlign(PApplet.CENTER,PApplet.CENTER);
				GLOBAL.processing.fill(224);
				GLOBAL.processing.text("Drag an artist\nto the blocks\non the right",160, 520);
				
				GLOBAL.processing.textAlign(PApplet.LEFT,PApplet.TOP);
				for(int i = 0; i<GLOBAL.artistsCompareList.size();i++) {
					GLOBAL.processing.text(GLOBAL.artistsCompareList.get(i).name, GLOBAL.block[i].x+GLOBAL.block[i].image.width*150f/GLOBAL.block[i].image.height+30,GLOBAL.block[i].y+GLOBAL.block[i].height/20);					
				}
			}
			filter.draw();
		}

		else if(GLOBAL.tabs.currentTabIndex == 1)
		{
			GLOBAL.weeklyMenu.draw();
			GLOBAL.processing.imageMode(PApplet.CORNER);
			GLOBAL.processing.image(GLOBAL.weeklyImage, 300, 100, GLOBAL.weeklyImage.width*300f/GLOBAL.weeklyImage.height, 300);
			GLOBAL.processing.textAlign(PApplet.LEFT, PApplet.TOP);
			GLOBAL.processing.fill(224);
			GLOBAL.processing.textFont(GLOBAL.tFont32);
			GLOBAL.processing.text("Atrist:  "+GLOBAL.weeklyDataCurrent.name, 300, 50);
			GLOBAL.processing.text("Play count for this week:   "+GLOBAL.weeklyDataCurrent.playcount, 300, 420);

			//GLOBAL.processing.textFont(GLOBAL.tFont);
			GLOBAL.processing.text("Choose an\nartist from\nthe list above", 70, 500);
			//GLOBAL.processing.text("Listeners: "+GLOBAL.weeklyDataCurrent..listeners, 300, 470);
			//PApplet.println(GLOBAL.weeklyDataCurrent.name);
		}
		else if(GLOBAL.tabs.currentTabIndex == 2){
			GLOBAL.map.draw();
		
			//testClock.draw();
			float minDist = 10000;
			int minIndex = -1;
			for(int i = 0; i<countryClock.size();i++) {
				countryClock.get(i).draw();
				float d = PApplet.dist(countryClock.get(i).xy[0], countryClock.get(i).xy[1], GLOBAL.processing.mouseX, GLOBAL.processing.mouseY);
				if(d<minDist) {
					minIndex = i;
					minDist = d;
				}
			}
			if(minDist<=25&& minIndex>=0) {
				GLOBAL.processing.fill(224,192);
				GLOBAL.processing.noStroke();
				GLOBAL.processing.rect(countryClock.get(minIndex).xy[0]-70, countryClock.get(minIndex).xy[1]-countryClock.get(minIndex).diameter/2-30, 140, 30);
				GLOBAL.processing.textAlign(PApplet.CENTER,PApplet.CENTER);
				GLOBAL.processing.textFont(GLOBAL.tFont);
				GLOBAL.processing.fill(32);
				GLOBAL.processing.text(countryClock.get(minIndex).name,countryClock.get(minIndex).xy[0], countryClock.get(minIndex).xy[1]-countryClock.get(minIndex).diameter/2-15);
			}
			GLOBAL.processing.noStroke();
			GLOBAL.processing.fill(224,192);
			GLOBAL.processing.rect(50, 5, 230, 40);
			for(int i=0; i<7; i++) {
				GLOBAL.processing.fill(countryClock.get(0).color[i]);
				GLOBAL.processing.rect(60+i*30, 10, 30, 20);
			}
			GLOBAL.processing.textFont(GLOBAL.fontTimes12);
			GLOBAL.processing.fill(0);
			GLOBAL.processing.textAlign(PApplet.CENTER,PApplet.TOP);
			GLOBAL.processing.text("0%", 60, 32);
			for(int i=0; i<6; i++) {
				GLOBAL.processing.text((int)PApplet.pow(2, i)+"%", 60+(i+1)*30, 32);
			}
			GLOBAL.processing.text("100%", 270, 32);
		}
		
		GLOBAL.processing.noStroke();
		GLOBAL.processing.fill(192);
		GLOBAL.processing.rect(0, 0, 50, 768);
		
		GLOBAL.tabs.drawAfterEverything();
		

	}
	
	public static void main(String[] args) {
		PApplet.main(new String[] { "applet.RadioGaga" });
	}
	
	// Color setup function, all colors should be set here, so every change will be global
	public void setupColors() {
		GLOBAL.colorBackground = color(0xcc, 0xff, 0x33);
		GLOBAL.colorText = color(150);
		GLOBAL.colorLinesLabelY = color(128);		
		GLOBAL.colorButtonLabel = color(255);
		GLOBAL.colorButtonBackground = color(0x32,0xcd,0x3,100);
		GLOBAL.colorButtonActive = color(0xa2,0x00,0x0c);
		GLOBAL.colorPlotArea = color(100,200);
		GLOBAL.colorBlu = color(136,204,238);
	}
	
	public void mouseDragged()
	{
		GLOBAL.mouseDragged = true;
		GLOBAL.mouseReleased = false;
		GLOBAL.mousePressed = false;
		
		//if(artistsTestButton.pressed)
		//	artistsTestButton.dragged = true;
		if(GLOBAL.tabs.currentTabIndex == 0)
		{
		//artistSelectPanel.mouseDragged();
			filter.artistList.mouseDragged();
		}
		else if(GLOBAL.tabs.currentTabIndex == 1) {
			GLOBAL.weeklyMenu.mouseDragged();
		}

		
	}
	
	public void mouseReleased()
	{
		GLOBAL.mouseDragged = false;
		GLOBAL.mouseReleased = true;
		GLOBAL.mousePressed = false;
		
		//artistsTestButton.mouseReleased();
		
		//artistSelectPanel.mouseReleased();
		if(GLOBAL.tabs.currentTabIndex == 0)
		{
			filter.mouseRelease();
			testTrackMenu.mouseReleased();
			testReleaseMenu.mouseReleased();
		}
		if(GLOBAL.tabs.currentTabIndex == 1) {
			GLOBAL.weeklyMenu.mouseReleased();
		}
	}
	public void mousePressed()
	{
		GLOBAL.mouseDragged = false;
		GLOBAL.mouseReleased = false;
		GLOBAL.mousePressed = true;
		
		//if(artistsTestButton.mouseOver())
		//	artistsTestButton.mousePressed();
		if(!GLOBAL.tabs.mousePressed()) {
		
			if(GLOBAL.tabs.currentTabIndex == 0)
			{
				if(filter.artistList.mouseOver() || filter.artistList.upButton.mouseOver() || (filter.artistList.downButton!= null && filter.artistList.downButton.mouseOver()))
				{
					filter.artistList.mousePressed();
				}
				else if(filter.artistList.items.size()>filter.artistList.dragDownSize && filter.artistList.selectBar!= null && filter.artistList.selectBar.mouseOver())
				{
					filter.artistList.selectBar.mousePressed();
				}
				else if(filter.countryList.mouseOver() || (filter.countryList.upButton!=null &&filter.countryList.upButton.mouseOver()) || (filter.countryList.downButton!=null && filter.countryList.downButton.mouseOver()) )
				{
					filter.countryList.mousePressed();
				}
				else if(filter.countryList.items.size()>filter.countryList.dragDownSize && filter.countryList.selectBar!=null && filter.countryList.selectBar.mouseOver())
				{
					filter.countryList.selectBar.mousePressed();
				}
			}
			
			if(GLOBAL.tabs.currentTabIndex == 0)
			{
				//testTrackMenu
				if(testTrackMenu.mouseOver() || (testTrackMenu.upButton!=null && testTrackMenu.upButton.mouseOver()) || (testTrackMenu.downButton!= null && testTrackMenu.downButton.mouseOver()))
					testTrackMenu.mousePressed();
				else if(testTrackMenu.items.size()>testTrackMenu.dragDownSize && testTrackMenu.selectBar.mouseOver())
				{
					testTrackMenu.selectBar.mousePressed();
				}
				//testReleaseMenu
				else if(testReleaseMenu.mouseOver() || (testReleaseMenu.upButton!=null && testReleaseMenu.upButton.mouseOver()) || (testReleaseMenu.downButton!= null && testReleaseMenu.downButton.mouseOver()))
					testReleaseMenu.mousePressed();
				else if(testReleaseMenu.items.size()>testReleaseMenu.dragDownSize && testReleaseMenu.selectBar.mouseOver())
				{
					testReleaseMenu.selectBar.mousePressed();
				}
			}
			if(GLOBAL.tabs.currentTabIndex == 1)
			{
				if(GLOBAL.weeklyMenu.mouseOver() || GLOBAL.weeklyMenu.upButton.mouseOver() || (GLOBAL.weeklyMenu.downButton!= null && GLOBAL.weeklyMenu.downButton.mouseOver()))
				{
					GLOBAL.weeklyMenu.mousePressed();
				}
				else if(GLOBAL.weeklyMenu.items.size()>GLOBAL.weeklyMenu.dragDownSize && GLOBAL.weeklyMenu.selectBar!= null && GLOBAL.weeklyMenu.selectBar.mouseOver())
				{
					GLOBAL.weeklyMenu.selectBar.mousePressed();
				}
			}
			
		}
	}
}
